//
//  HomeViewController.m
//  1gene
//
//  Created by 1jiyin on 16/2/26.
//  Copyright © 2016年 1jiyin. All rights reserved.
//
//***************************首页***************************
#import "HomeViewController.h"

@interface HomeViewController ()

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self createUI];
    NSLog(@"首页");
    // Do any additional setup after loading the view.
}
-(void)createUI
{
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor=[UIColor redColor];
    btn.frame=CGRectMake(100, 200, 100, 50);
    [btn setTitle:@"确定" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(myClearCacheAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}
//#pragma mark === 暂时不用清除缓存=====
//-(void)myClearCacheAction{
//    [self userLogin];
////    dispatch_async(
////                   dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
////                   , ^{
////                       NSString *cachPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
////                       
////                       NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachPath];
////                       NSLog(@"files :%lu",(unsigned long)[files count]);
////                       for (NSString *p in files) {
////                           NSError *error;
////                           NSString *path = [cachPath stringByAppendingPathComponent:p];
////                           if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
////                               NSLog(@"开始清理缓存");
////                               [[NSFileManager defaultManager] removeItemAtPath:path error:&error];
////                           }
////                       }
////                       [self performSelectorOnMainThread:@selector(clearCacheSuccess) withObject:nil waitUntilDone:YES];});
//}
//-(void)userLogin
//{
//    NSURL * url = [NSURL URLWithString:@"http://www.sgict.com.cn:7001/query/search/comm/contgoods.jsp"];
//    NSMutableURLRequest * req = [[NSMutableURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:100];
//    [req setHTTPMethod:@"POST"];
//    
//    NSString * strData = [NSString stringWithFormat:@"billno=%@&choice=2&Submit22.x=17&Submit22.y=19",@"123"];
//    
//    NSData * data = [ strData dataUsingEncoding:NSUTF8StringEncoding];
//    
//    [req setHTTPBody:data];
//    
//    NSURLConnection * conn = [[NSURLConnection alloc]initWithRequest:req delegate:self];
//    if( conn == nil )
//    {
//        NSLog(@"conn create error");
//    }else{
//        NSLog(@"%@",conn);
//    }
//}
//
//-(void)clearCacheSuccess
//{
//    NSLog(@"清理成功");
//    
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/



//清理缓存
/*
 
 -(void)removeCache
 {
 //===============清除缓存==============
 NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];
 NSArray *files = [[NSFileManager defaultManager] subpathsAtPath:cachePath];
 //    NSLog(@"文件数 ：%d",[files count]);
 for (NSString *p in files)
 {
 NSError *error;
 NSString *path = [cachePath stringByAppendingString:[NSString stringWithFormat:@"/%@",p]];
 if([[NSFileManager defaultManager] fileExistsAtPath:path])
 {
 [[NSFileManager defaultManager] removeItemAtPath:path error:&error];
 }
 }
 }
 
 */
@end
